<template>
	<view style="background: #F0E3CE;min-height: 100vh;"
		:style="{background:'url('+Imgbase+'/new_goodmy_bgc.png)','background-size':'100%',}">

		<view class="padding-top-50 padding-left-40" style="" @click="back">
			<image class="w-80 h-80" :src="Imgbase+'/'+skin+'_goodpoor_img1.png'" mode="aspectFit">
			</image>
		</view>

		<!-- 主页 -->
		<view class="" v-show="pagename == 'index'">
			<!-- 判断是不是新年皮肤  选择滚动条的位置 -->
			<view class="">
				<view class="padding-top-20 padding-left-20 w-380" v-if="skin == 'newyear'">
					<u-notice-bar :text="explain2" bgColor="" color="#fff"></u-notice-bar>
				</view>

				<view class="padding-top-20 margin-auto padding-left-160 padding-right-30" v-else>
					<!-- 经典皮肤 -->
					<u-notice-bar :text="explain2" v-if="skin == 'classics'"></u-notice-bar>

					<!-- 冬季皮肤 -->
					<u-notice-bar :text="explain2" bgColor="rgba(157,183,223, .5)" color="#fff" v-else></u-notice-bar>
				</view>
			</view>

			<!-- 判断是不是新年皮肤  选择按钮样式 -->
			<view class="">
				<view class="padding-top-30 flex-between padding-left-60 padding-right-60" v-if="skin == 'newyear'">
					<view class="" v-for="(item,index) in 5" :key="index" @click="topicon(index)">
						<image class="w-78 h-88" :src="Imgbase + '/newyear_goodindex_icon' +(index + 1)+'.png'"
							mode="aspectFit">
						</image>
					</view>
				</view>

				<view class="padding-top-30 flex-between padding-left-60 padding-right-60" v-else>
					<view class="" v-for="(item,index) in 5" :key="index" @click="topicon(index)">
						<image v-if="index == 1" class="w-78 h-88" :src="Imgbase + '/new_goodindex_img5n.png'"
							mode="aspectFit">
						</image>

						<image v-else class="w-78 h-88" :src="Imgbase + '/new_goodindex_img' +(index + 4)+'.png'"
							mode="aspectFit">
						</image>
					</view>
				</view>
			</view>

			<view class="padding-top-15 margin-bottom-20" style="position: relative;">
				<!-- 轮播 -->
				<view style="border-radius: 12px;overflow: hidden;height: 275rpx;width: 94%;margin: 0 auto;">
					<swiper class="screen-swiper square-dot" :indicator-dots="true" :circular="true" :autoplay="true"
						interval="5000" duration="500">
						<swiper-item v-for="(item,index) in swiperList" :key="index" @click="showSwiper(item.navi_url)">
							<image :src="item.adimage" style="height: 100%;width: 100%;" mode=""
								v-if="item.type=='image'">
							</image>
							<video :src="item.adimage" autoplay loop muted :show-play-btn="false" :controls="false"
								objectFit="cover" v-if="item.type=='video'"></video>
						</swiper-item>
					</swiper>
				</view>

				<view class="winter_img w-200 h-200" v-if="skin == 'winter'">
					<image class="h100 w100" :src="Imgbase + '/winter_goodindex_img1.png'" mode="aspectFit">
					</image>
				</view>
			</view>


			<view class="flex-between padding-left-20 padding-right-20" :style="[{height:TabCur==0?'320rpx':'0rpx'}]"
				style="transition: .5s;">
				<view class="h100" style="width: 31%;" @click="gopage(0)">
					<image class="h100" :src="Imgbase + '/new_goodindex_img1.png'" mode="aspectFit">
					</image>
				</view>
				<view class="h100" style="width: 66%;">
					<view class="w100">
						<image @click="gopage(2)" style="transition: .5s;" :style="[{height:TabCur==0?'155rpx':'0rpx'}]"
							:src="Imgbase + '/new_goodindex_imgn3.png'" mode="aspectFit">
						</image>
					</view>

					<view class="w100 h-150 radius-15 flex-center Bfont fff">
						<button class="w100 h-150 " :disabled="loading" :loading="loading" @click="keepon()"
							style="display: flex;justify-content: center;overflow: hidden;background-color:transparent;padding: 0;">
							<image class="w100 h100" :src="Imgbase + '/new_goodindex_imgn4.jpg'" mode="aspectFill">
							</image>
						</button>
					</view>
				</view>
			</view>

			<!-- <view class="w100 h-100 flex-center fff Bfont font-40" style="background-color: #2B9C35;letter-spacing: 6rpx;"
				@click="gopage(4)">
				暗夜赏
			</view> -->

		</view>

		<!-- 社区 -->
		<view class="" v-show="pagename == 'socity'">
			<view class="community-top h-1400 w100 "
				:style="{background:'url('+Imgbase+'/new_goodsoc_bgc2.png)','background-size':'100%',}">

				<view class="flex-between padding-top-90 padding-left-100 padding-right-60">
					<view class="w-160 h-160 padding-top-10" @click="torank()">
						<!-- <image class="w100 h100" :src="Imgbase + '/socity_5.png'" mode="aspectFit"></image> -->
						<image class="w100 h100" :src="Imgbase + '/new_goodsoc_img2n.png'" mode="aspectFit"></image>
					</view>


					<view class="w-170 h-170">
						<image class="w100 h100" @click="toPage('index','Pray',pray_number)"
							:src="Imgbase + '/new_goodsoc_lucknum'+ pray_number  +'.png'" mode="aspectFit"></image>
					</view>
					<view class="w-160">

					</view>
					<!-- 免费抽奖 -->
					<!-- <view class="h-150" @click="gofree">
							<image class="w100 h100" :src="Imgbase + '/1zhan_new_chou.png'" mode="aspectFit"></image>
						</view> -->

				</view>

				<view class="padding-top-170 text-center w100">
					<view class="w-600 h-100" style="margin: 0 auto -45rpx;position: relative;z-index: 99;">
						<image class="w100 h100" :src="Imgbase + '/new_goodsoc_img5n.png'" mode="aspectFit"></image>
					</view>

					<view class="w100">
						<button class="w100 h-300"
							style="display: flex;justify-content: right;overflow: hidden;background-color:transparent;"
							open-type="share">
							<image class="w100 h-300" :src="Imgbase + '/new_goodsoc_img6n.png'" mode="aspectFit">
							</image>
						</button>
					</view>

				</view>
			</view>



			<view class="cu-modal" :class="modalName=='Modal'?'show':''" @tap="hideModal">
				<view class="cu-dialog" style="background-color:initial;">
					<view class="bg-img"
						:style="{background:'url('+Imgbase+'/noproject2.png) no-repeat','background-size':'100% 100%','height':'460rpx'}">
					</view>
				</view>
			</view>
		</view>

		<!-- 我的 -->
		<view class="padding-top-10 padding-left-20 padding-right-20" v-show="pagename == 'user'">

			<view class="w100  df ">
				<view class="w-170 h-170 margin-top-30 margin-left-40 padding-6" @click="copyname(user.username)"
					:style="{background:'url('+Imgbase+'/new_goodmy_img1.png)','background-size':'100% 100%',}">
					<!-- :style="{background:'url('+user.avatar+')','background-size':'100% 100%',}" -->
					<image class="w100 h100 radiusb-50" style="overflow: hidden;" :src="user.avatar" mode="aspectFill">
					</image>
				</view>
				<view class="w-420 margin-top-30 padding-left-30">
					<view class="font-40 w100 font-weight-500 one-line" style="color: #A15B25;">
						{{username}}
					</view>
					<view class="font-22 padding-top-15" style="color: #A15B25;">
						LV{{level}}({{levelnow}}/{{levelall}})
					</view>

					<view class="w100 h-32 padding-5 margin-top-15" @click="toPage('index','level')"
						style="position: relative;">

						<view class="w100 h-25 schedule" style="background-color: #FFD08F;">
							<view class="h100" style="background-color: #FF2D2D;"
								:style="[{ width:loading?levelpoint:0}]">
							</view>
						</view>

						<view class="w100 h100" style="position: absolute;z-index: 9999;top: 0;left: 0;"
							:style="{background:'url('+Imgbase+'/new_goodmy_img3.png)','background-size':'100% 100%',}">
						</view>
					</view>

				</view>
			</view>

			<view class="w100  padding-top-135" style="height: 1300rpx;margin-top: -145rpx;"
				:style="{background:'url('+Imgbase+'/new_goodmy_bgc1.png)','background-size':'100% 100%',}">
				<view class="padding-top-45 padding-bottom-10 padding-left-35 font-22" style="color: #A15B25;">
					我的资产
				</view>
				<view class="flex-between  padding-left-130 padding-right-130">
					<view class="w-130 h-140 radius-20 fff text-center " v-for="(item,index) in myinfor" :key="index"
						style="background-color: #FF9B4E;border: 4rpx solid #A15B25;" @click="gopage('water')">
						<view class="padding-top-20">
							{{item.price}}
						</view>
						<view class="padding-top-20 font-26">
							{{item.text}}
						</view>
					</view>
				</view>

				<view class="padding-top-120 padding-left-40 ">
					<view class="w100 text-center padding-right-40">
						<image class="w-600 h-130" :src="Imgbase + '/new_goodindex_img7.png'" mode="aspectFit"
							@click="topicon(3)">
					</view>

					<view class="">
						<view class="font-22 padding-top-15 padding-bottom-25" style="color: #A15B25;">
							我的功能
						</view>
						<view class="btnitem margin-bottom-15">
							<image class="w100 h-80" :src="Imgbase + '/new_goodmy_img15.png'" mode="aspectFit"
								@click="toPage('goodspoor','scoreshop')">
							</image>
						</view>
						<view class="btnitem margin-bottom-15">
							<image class="w100 h-80" :src="Imgbase + '/new_goodmy_img8.png'" mode="aspectFit"
								@click="toPage('goodspoor','water',1)">
							</image>
						</view>
						<view class="btnitem margin-bottom-15">
							<button open-type="contact"
								style="display: flex;justify-content: center;overflow: hidden;background-color:transparent;padding: 0;">
								<image class="w100 h-80" :src="Imgbase + '/new_goodmy_img14.png'" mode="aspectFit">
								</image>
							</button>
						</view>
						<view class="btnitem margin-bottom-15">
							<image class="w100 h-80" :src="Imgbase + '/new_goodmy_img10.png'" mode="aspectFit"
								@click="toPage('goodspoor','usersave')">
							</image>
						</view>
					</view>
				</view>

			</view>
			<!-- <view style="position: fixed;right: 1%;bottom: 20%;">
				<image class="w-90 h-90" :style="{'transform': 'rotate('+360*refreshtime+'deg)','transition': 'all 1s'}"
					@click="startR" :src="Imgbase + '/new_goodresh.png'" mode="aspectFit"></image>
			</view> -->


			<view class="h-200">

			</view>
		</view>


		<view style="width: 100%;height: 140upx;"></view>

		<!-- <view class="w100 h-160 tabbars ">
			<view class="flex-between h-140 padding-left-90 padding-right-90" style="position: relative;z-index: 999;">
				<view class="" @click="seletab('index')">
					<view class="w-120 h-140 text-center padding-bottom-10">
						<image :src=" Imgbase+'/new_good_tab1.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="" @click="seletab('socity')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/new_good_tab4.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="padding-bottom-10" @click="seletab('user')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/new_good_tab5.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
			</view>
			<view class="bgcs">

			</view>
			<view class="bgcs_top">

			</view>
		</view> -->

		<!-- 经典皮肤 -->
		<view class="w100 h-160 tabbars " v-if="skin == 'classics'">
			<view class="flex-between h-140 padding-left-90 padding-right-90" style="position: relative;z-index: 9999;">
				<view class="" @click="seletab('index')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/new_good_tab1.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="" @click="seletab('socity')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/new_good_tab4.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="padding-bottom-10" @click="seletab('user')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/new_good_tab5.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
			</view>
			<view class="bgcs">

			</view>
			<view class="bgcs_top">

			</view>
		</view>

		<!-- 冬季皮肤 -->
		<view class="w100 h-160 tabbars " v-if="skin == 'winter'">
			<view class="flex-between h-140 padding-left-90 padding-right-90" style="position: relative;z-index: 9999;">
				<view class="padding-bottom-50" @click="seletab('index')">
					<view class="w-130 h-150 text-center ">
						<image :src=" Imgbase+'/winter_goodtab1.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="" @click="seletab('socity')">
					<view class="w-115 h-115 text-center">
						<image :src=" Imgbase+'/winter_goodtab4.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="padding-bottom-15" @click="seletab('user')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/winter_goodtab5.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
			</view>
			<view class="bgcswinter">

			</view>
			<view class="bgcs_topwinter">

			</view>
		</view>

		<!-- 新年皮肤 -->
		<view class="w100 h-160 tabbars " v-if="skin == 'newyear'">
			<view class="flex-between h-120 padding-left-90 padding-right-90" style="position: relative;z-index: 9999;">
				<view class="" @click="seletab('index')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/newyear_goodtab1.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="" @click="seletab('socity')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/newyear_goodtab4.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
				<view class="padding-bottom-10" @click="seletab('user')">
					<view class="w-120 h-120 text-center">
						<image :src=" Imgbase+'/newyear_goodtab5.png'" mode="aspectFit" class="w100 h100 margin-top-10">
						</image>
					</view>
				</view>
			</view>
			<view class="bgcsnewyear w100 h-200"
				:style="{background:'url('+Imgbase+'/newyear_goodbgc.png)','background-size':'100% 100%',}">

			</view>
		</view>

		<view class="free_item fff Bfont" @click="back()">

			<view class="w-90 text-center padding-top-12 padding-bottom-12 radius-14 font-26"
				style="background-color: #EFB165;">
				<view class="" style="letter-spacing: 4rpx;">
					点击
				</view>
				<view class="" style="letter-spacing: 4rpx;">
					跳转
				</view>
			</view>
		</view>

		<!-- 新手必看弹窗 -->
		<u-modal :show="xinshow" title="新手必看" :content='explain1' closeOnClickOverlay @close="xinclose"
			@confirm="xinclose" confirmColor="#EFB165"></u-modal>

		<!-- 皮肤选择 -->
		<u-picker :show="skinshow" :columns="zh_columns" @cancel="skinshow = false" @confirm="chooseskin"
			closeOnClickOverlay></u-picker>

		<u-toast ref="uToast"></u-toast>


		<!-- <ad-rewarded-video ref="adRewardedVideo" adpid="1248501539" adUnitld="1248501539" @close="onadclose"
			@load="onadload" :url-callback="urlCallback" :loadnext="true" v-slot:default="{loading, error}">

		</ad-rewarded-video> -->


		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import md5 from '@/utils/md5.js'
	export default {
		data() {
			return {
				pagename: 'index',
				PageCur: 1,
				Imgbase: getApp().globalData.Imgbase,
				refreshtime: 0,
				swiperList: [],
				TabCur: 0,
				scrollLeft: 0,
				tap: [],
				ids: [],
				list: [],
				page: 1,
				count: 0,
				hasData: true,
				keyword: '',
				orderpicker: ['最新发售', '价格升序', '价格降序', '剩余升序', '剩余降序'],
				orderids: [1, 2, 3, 4, 5],
				orderindex: 0,
				orderid: 1,
				loadModal: false,
				poor_type: uni.getStorageSync('poor_type') || 0,
				heights: '',
				marginl: '',
				value1: 0,
				logins: '',
				tokens: '',
				tokends: '',
				tokenas: '',
				explain1: '',
				small_list: [],
				xinshow: false,
				explain2: '本平台为免费体验版程序，不可发货',
				urlCallback: {
					userId: '',
					extra: ''
				},
				setm: '',
				session_key: '', // 判断有无session_key
				setval: false, //判断是否轮询，true为轮询
				skin: 'classics',
				skinshow: false,
				columns: [],
				zh_columns: [],
				newname: '',
				level: 1,
				levelpoint: '60%',
				levelnow: 0,
				levelall: 0,
				refreshtime: 0,
				userid: 0,
				username: '',
				user: [],
				myinfor: [{
						text: '体验币',
						price: ''
					},
					// {
					// 	text: '余额',
					// 	price: ''
					// },
					{
						text: '积分',
						price: ''
					},
					// {
					// 	text: '红豆',
					// 	price: ''
					// }
				],
			};
		},
		// 分享
		onShareAppMessage(res) {
			let _this = this;
			console.log(res.from)
			if (res.from == 'menu') {
				return {
					title: '',
					path: '/pages/goodspoor/index',
					imageUrl: 'https://oqyf-1305090490.cos.ap-shanghai.myqcloud.com/front/1zhan_new_logo.png',
				}
			} else {
				return {
					title: '好友助力',
					path: '/pagesA/free/Assist?id=' + _this.userid,
					imageUrl: 'https://oqyf-1305090490.cos.ap-shanghai.myqcloud.com/front/1zhan_new_logo.png',
				}
			}

		},
		mounted() {
			// _this.login();

		},
		onLoad() {
			let _this = this;
			_this.loadlist();
			uni.hideTabBar()

			this.judgePlatForm()
			this.showbue()
			this.exshuo()
			this.Init();
		},
		onShow() {
			this.userFront()
			this.session_key = uni.getStorageSync('session_key')

			console.log('session_key:', this.session_key)

			if (uni.getStorageSync('skin')) {

				// this.skin = uni.getStorageSync('skin')

			}
			this.skins()
		},
		onReady() {
			// this.isLoading = true;
			this.$refs.adRewardedVideo.load();
		},
		methods: {
			// 发放体验币
			async lookEnd() {
				let _this = this
				// 加密
				let str = _this.$uniApi.mdnum();
				var md5Str = md5.hex_md5(str[1])

				let item = await this.$api.post('Uniad/lookEnd', {
					token: uni.getStorageSync('token'),
					nonce: str[2],
					sign: md5Str,
					timestamp: str[0]
				})

				if (item.code == 1) {
					_this.$refs.uToast.show({
						message: item.msg,
					})
				}
			},
			onadload(e) {
				console.log(e)
			},
			torank() {
				uni.navigateTo({
					url: '/pagesA/free/rank'
				})
			},
			back() {
				uni.navigateBack()
			},
			chooseskin(e) {
				this.skinshow = false
				this.setSkin(this.columns[e.indexs[0]])
			},
			// 设置皮肤
			async getSkin() {
				let _this = this
				let item = await this.$api.post('user/skins', {
					token: uni.getStorageSync('token'),
				})

				uni.setStorageSync('skin', item.data.skin);
				this.skin = item.data.skin
			},
			// 选择皮肤接口
			async setSkin(e) {
				let _this = this
				let item = await this.$api.post('user/setSkin', {
					token: uni.getStorageSync('token'),
					skin: e
				})
				if (item.code == '1') {
					this.getSkin()

					this.$refs.uToast.show({
						message: item.msg,
					})
				}
			},
			// 皮肤选择
			async skins() {
				let _this = this
				let item = await this.$api.post('user/skins', {
					token: uni.getStorageSync('token'),
				})
				this.zh_columns = []
				this.zh_columns.push(item.data.zh_list)
				this.columns = item.data.list
			},
			// 查询体验币
			async queryAdGift() {
				let _this = this;

				return
				let item = await this.$api.post('Uniad/queryAdGift', {
					extra: _this.urlCallback.extra,
					token: uni.getStorageSync('token'),
				})
				if (item.data.result == 1) {
					clearInterval(_this.setm);
					this.session_key = uni.getStorageSync('session_key')


					uni.showToast({
						icon: 'none',
						title: item.msg
					});

					let res = ''
					for (let n = 1; n <= 10; n++) {
						res += uni.$u.random(0, 9)
					}
					_this.urlCallback.extra = res
				}
			},
			keepon(e) {
				let _this = this
				if (this.session_key == '') {
					if (_this.setval) {
						uni.showToast({
							icon: 'none',
							title: '正在查询体验币，请稍候',
						});

					} else {
						uni.showToast({
							icon: 'none',
							title: '登录过期，请重新登录',
						});

						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/login/login'
							})
						}, 1000)
					}

				} else {

					this.$refs.adRewardedVideo.show();

					this.setm = setInterval(() => {
						_this.setval = true
						_this.session_key = false
						_this.queryAdGift()

					}, 1000)
				}
			},
			onadclose(e) {
				let _this = this

				// console.log(e)

				const detail = e.detail
				// 用户点击了【关闭广告】按钮
				if (detail && detail.isEnded) {
					// 正常播放结束
					console.log("onadclose " + detail.isEnded);
					_this.lookEnd()
					if (_this.setval == true) {
						setTimeout(() => {
							clearInterval(_this.setm);
							_this.setval = false
							this.session_key = uni.getStorageSync('session_key')

							let res = ''
							for (let n = 1; n <= 10; n++) {
								res += uni.$u.random(0, 9)
							}
							_this.urlCallback.extra = res
						}, 6000)
					}

				} else {
					// 播放中途退出
					console.log("onadclose " + detail.isEnded);
					clearInterval(_this.setm);
					_this.setval = false
					this.session_key = uni.getStorageSync('session_key')

					let res = ''
					for (let n = 1; n <= 10; n++) {
						res += uni.$u.random(0, 9)
					}
					_this.urlCallback.extra = res
				}
			},
			onaderror(e) {
				// 广告加载失败
				console.log("onaderror: ", e.detail);
			},
			// 跳转小程序
			gofree() {
				uni.navigateToMiniProgram({
					appId: 'wx43043a1f69c6ea61',
					success(res) {
						// 打开成功
					}
				})
			},
			// 邮寄说明
			exshuo() {
				let _this = this;
				uni.request({
					url: _this.$globals.apibase + '/api/Index/explain',
					data: {
						id: 19
					},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						// _this.explain2 = res.data.data.desc.content;
					}
				});
			},
			gopage(e) {
				switch (e) {
					case 0: //无底池
						uni.navigateTo({
							url: '/pagesA/free/list'
						})
						break;
					case 1: // 免费抽奖
						uni.navigateTo({
							url: '/pagesA/advanced/free'
						})
						break;
					case 2: // 摘星赏
						uni.navigateTo({
							url: '/pagesA/free/star'
						})
						break;
					case 3: // 判断有无session_key
						break;
					case 'water': // 体验币流水
						uni.navigateTo({
							url: '/pagesA/free/water'
						})
						break;
				}
			},
			// 关闭新手必看弹窗
			xinclose() {
				this.xinshow = false
			},
			topicon(e) {
				switch (e) {

					case 0: // 新手必看
						this.goon()
						return
						this.xinshow = true
						break;

					case 1: // 切换皮肤
						this.skinshow = true
						return
						uni.navigateTo({
							url: '/pagesA/newpage/laxin'
						})
						break;
					case 2: // 积分商城
						uni.navigateTo({
							url: '/pages/goodspoor/scoreshop'
						})
						break;
					case 3: // 每日签到
						uni.navigateTo({
							url: '/pages/goodspoor/signin'
						})
						break;

					case 4: // 特价商城
						uni.switchTab({
							url: '/pages/index/kpindex'
						})
						break;
				}
			},
			// 新手必看
			showbue() {
				let _this = this;
				uni.request({
					url: _this.$globals.apibase + '/api/Index/explain',
					data: {
						id: 20
					},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						_this.explain1 = res.data.data.desc.content;
					}
				});
			},
			goon() {
				uni.showToast({
					icon: 'none',
					title: '此功能正在开发中'
				});
			},
			seletab(i) {
				this.pagename = i
				if (i == 'user') {
					this.userFront()
				}
			},
			changepoorType(poor_type) {
				let _this = this

				this.poor_type = poor_type;
				uni.setStorageSync('poor_type', poor_type);
				this.TabCur = 0;

				if (poor_type == 2) {
					_this.page = 1;
					_this.list = [];
					_this.hasData = true;
					_this.tap = [];
					_this.ids = [];
					_this.loadlist();
				} else {
					this.loadtypes();
				}
			},
			orderPickerChange(e) {
				this.orderindex = e.detail.value
				this.orderid = this.orderids[this.orderindex]
				this.page = 1;
				this.list = [];
				this.hasData = true;
				this.loadlist();
			},
			search() {
				this.page = 1;
				this.list = [];
				this.hasData = true;
				this.loadlist();
			},
			startR() {
				if (getApp().globalData.couldFresh == true) {
					getApp().globalData.couldFresh = false;
					setTimeout(() => {
						getApp().globalData.couldFresh = true;
					}, 1000)
				} else {
					return;
				}
				this.refreshtime += 1;
				let _this = this;
				_this.loadModal = true;
				this.page = 1;
				//this.list = [];
				this.hasData = true;
				this.loadlist(200, true);
			},
			async Minlogin(code) {
				let _this = this;
				let item = await this.$api.post('Minlogin/login', {
					code: code,
					ver: this.$mpVer,
					use: 'ceshi'
				})
				if (item.code == '1') {
					uni.setStorageSync('token', item.data.token);

				} else {
					uni.showToast({
						icon: 'none',
						title: '登录失败'
					});
				}
				// _this.tokenas = uni.setStorageSync('token','5dc6e2ba-7efe-465d-8dcd-6f64201613d8')
				uni.setStorageSync('token', '5dc6e2ba-7efe-465d-8dcd-6f64201613d8')

			},
			login() {
				let _this = this;
				let t = this;
				if (uni.getStorageSync('token') == '') {
					/*uni.reLaunch({
						url: `/pages/login/login`
					});*/

					wx.showModal({
						title: '温馨提示',
						content: '正在请求您的个人信息',
						success(res) {
							if (res.confirm) {


								uni.login({
									provider: 'weixin',
									success: function(loginRes) {
										let code = loginRes.code;
										console.log(code);
										// _this.tokens = code
										// t.Minlogin(code)
										// return
										// uni.hideLoading();
										// uni.showToast({
										// 	icon: 'none',
										// 	title: '测试app跳转'
										// });

										uni.request({
											url: _this.$globals.apibase +
												'/api/Minlogin/login',
											data: {
												code: code,
												// avatar: res.userInfo
												// 	.avatarUrl,
												// nickname: res.userInfo
												// 	.nickName,
												// gender: res.userInfo
												// 	.gender,
												// encryptedData: res
												// 	.encryptedData,
												// iv: res.iv,
												ver: _this.$mpVer,
												use: 'ceshi'
											},
											method: 'POST',
											header: {
												'content-type': 'application/json'
											},
											success: (res) => {
												uni.showToast({
													icon: 'none',
													title: res.data.msg
												});
												_this.tokends = res.data.msg
												// _this.tokenas = res.data.data.token
												if (res.data.code ==
													'1') {
													uni.setStorageSync(
														'token',
														res.data
														.data.token
													);
													try {
														uni.setStorageSync(
															'token',
															res
															.data
															.data
															.token
														);
														//在此运行代码
													} catch (err) {
														_this.tokens =
															'缓存失败'
														//在此处理错误
														uni.showToast({
															icon: 'none',
															title: '储存失败'
														});
													}
												} else {
													uni.showToast({
														icon: 'none',
														title: '登录失败'
													});
												}

												let token = uni
													.getStorageSync(
														'token'
													);
												if (token != '') {
													uni.showToast({
														icon: 'none',
														title: '登录成功'
													});
												} else {
													uni.showToast({
														icon: 'none',
														title: '登录失败'
													});
												}
												uni.hideLoading();
											},
											fail: (res) => {
												console.log(res)
												_this.tokens = res.errMsg
												_this.tokenas = res.errno
												uni.showToast({
													icon: 'none',
													title: '用户登录失败'
												});
											}
										});
									},
								});



							}
						}
					})
				} else {}
			},
			showSwiper(url) {
				if (url == '') {

				} else {
					uni.navigateTo({
						url: `/pages/goodspoor/web?url=${url}`
					});
				}
			},
			judgePlatForm() {

			},
			showGood(id) {
				let lookurl = '';
				if (this.poor_type == 0) {
					lookurl = `/pagesA/goodspoor/poordetail?id=${id}`;
				}
				if (this.poor_type == 1) {
					lookurl = `/pagesA/goodspoor/poordetail?id=${id}`;
				}
				if (this.poor_type == 2) {
					lookurl = `/pagesA/advanced/hidpoordetail?id=${id}`;
				}
				uni.navigateTo({
					url: lookurl
				});
			},
			tabSelect(e) {
				this.small_list = []
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
				this.page = 1;
				this.list = [];
				this.hasData = true;
				this.loadlist();
			},
			getWheels() {
				let _this = this;
				uni.request({
					url: _this.$globals.apibase + '/api/Luckgoods/wheel',
					data: {},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						_this.swiperList = res.data.data.list;
					}
				});
			},
			loadtypes() {
				let _this = this;
				uni.request({
					url: _this.$globals.apibase + '/api/Luckgoods/type',
					data: {
						type: _this.poor_type,
						token: uni.getStorageSync('token'),
					},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						_this.page = 1;
						_this.list = [];
						_this.hasData = true;
						_this.tap = res.data.data.names;
						_this.ids = res.data.data.ids;
						_this.tap.unshift('推荐')
						_this.ids.unshift(-1)
						_this.loadlist();
					}
				});
			},
			loadlist(point = 0, isfresh = false) {
				let _this = this;
				_this.loadModal = true;
				let lookurl = '';
				if (_this.poor_type == 0 || _this.poor_type == 2) {
					lookurl = _this.$globals.apibase + '/api/Luckgoods/poorlist';
				}
				if (_this.poor_type == 1) {
					lookurl = _this.$globals.apibase + '/api/Luckgoods/poorlist';
				}
				uni.request({
					url: lookurl,
					data: {
						page: _this.page,
						id: _this.ids[_this.TabCur] == -1 ? 0 : _this.ids[_this.TabCur],
						keyword: _this.keyword,
						orderid: _this.orderid,
						token: uni.getStorageSync('token'),
						is_hidden: _this.poor_type == 2 ? 1 : 0
					},
					method: 'POST',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						_this.loadModal = false;
						if (res.data.code == '401') {
							uni.setStorageSync('token', '');
						}
						if (res.data.code == '1') {
							if (_this.poor_type == 0 && _this.ids[_this.TabCur] == 0) {
								_this.small_list = res.data.data.small_list
							} else {
								_this.small_list = []
							}
							if (isfresh == true) {
								_this.list = [];
							}
							_this.count = res.data.data.count;
							for (let i = 0; i < res.data.data.list.length; i++) {
								_this.list = _this.list.concat(res.data.data.list[i])
							}
							console.log(_this.list)
							if (_this.list.length >= _this.count) {
								_this.hasData = false
							}
							if (point != 0) {
								uni.createSelectorQuery().select(".app").boundingClientRect(
									data => { //目标节点
										uni.createSelectorQuery().select(".al")
											.boundingClientRect(
												(
													res) => { //最外层盒子节点
													uni.pageScrollTo({
														duration: 0, //过渡时间必须为0，uniapp bug，否则运行到手机会报错
														scrollTop: point, //滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离
													})
												}).exec()
									}).exec();
							}
						}
						if (res.data.code == '0') {
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
					}
				});
			},
			Init() {
				this.page = 1;
				this.list = [];
				this.hasData = true;
				this.keyword = '';
				this.getWheels();
				this.loadtypes();
			},
			async userFront(e) {
				let _this = this
				let item = await this.$api.post('Userways/userFront', {
					token: uni.getStorageSync('token'),
				})
				_this.user = item.data.user_desc
				_this.username = item.data.user_desc.nickname
				_this.myinfor[0].price = item.data.user_desc.exp_coin
				_this.myinfor[1].price = item.data.user_desc.score

				_this.userid = item.data.user_desc.id
				_this.levelall = item.data.level_mes.endpoint;
				_this.levelnow = item.data.user_desc.empirical;
				_this.level = item.data.level_mes.level;
				_this.levelpoint = Number(_this.levelnow / _this.levelall * 100).toFixed(1) + '%'

				// 广告			// 获取用户id
				_this.urlCallback.userId = item.data.user_desc.userUnique.open_id
				let res = ''
				for (let n = 1; n <= 10; n++) {
					res += uni.$u.random(0, 9)
				}
				_this.urlCallback.extra = res

			},
			toPage(folder, name, id = -1) {
				if (id == -1) {
					uni.navigateTo({
						url: `/pages/${folder}/${name}`
					});
				} else {
					uni.navigateTo({
						url: `/pages/${folder}/${name}?id=${id}`
					});
				}
			},
			hideModal(e) {
				this.modalName = null
				this.newname = ''
			},
			copyname(e) {
				uni.setClipboardData({
					data: e,
					showToast: false,
					success: function() {
						uni.showToast({
							title: '复制成功'
						});
					}
				})
			},
		},
		onReachBottom() {
			let _this = this
			if (_this.hasData) {
				_this.page++;
				_this.loadlist();
			}
		},
	}
</script>

<style lang="less" scoped>
	// 主页
	.btn_left {
		position: absolute;
		top: 0;
		left: 0;
		width: 42%;
	}

	.btn_right {
		position: absolute;
		top: 0;
		right: 0;
		width: 42%;
	}

	.winter_img {
		position: absolute;
		left: 5rpx;
		top: -20rpx;
		z-index: 5;
	}

	.winter_img1 {
		position: absolute;
		left: 0rpx;
		top: 10rpx;
		z-index: 1;
		width: 80%;
	}

	.newyear_img1 {
		position: absolute;
		left: 0rpx;
		top: 10rpx;
		z-index: 1;
		width: 70%;
	}

	.text-ff {
		position: absolute;
		bottom: 15rpx;
		background-color: rgba(255, 255, 255, .5);
		width: 75%;
		text-align: center;
		border-radius: 25rpx;
		left: 12.5%;
		color: #000;
		padding-bottom: 5rpx;
	}

	.skinco {
		background-color: #F0E3CE;
		box-shadow:
			5px 5px 5px #00000014,
			5px -5px 5px #00000014,
			-5px 5px 5px #00000014,
			-5px -5px 5px #00000014;
	}

	.skinwinter {
		background: url('https://oqyf-1305090490.cos.ap-shanghai.myqcloud.com/front/winter_goodindex_img5n.png');
		background-size: 100% 100%;
	}

	.free_item {
		position: fixed;
		right: 1%;
		bottom: 13%;
		z-index: 999;
	}

	.items_box {
		width: 47%;
		background-color: #F0E3CE;
		box-shadow:
			5px 5px 5px #00000014,
			5px -5px 5px #00000014,
			-5px 5px 5px #00000014,
			-5px -5px 5px #00000014;
		float: left;
		margin-right: 5%;
		margin-bottom: 60rpx;

		.quanju {
			color: #ff5555;
			border-radius: 8rpx;
			border: solid 2rpx #ff5555;
			min-width: 45rpx;
			height: 24rpx;
			line-height: 20rpx;
		}

		.price {
			color: #e60000;
		}

		.jindu {
			width: 314rpx;
			height: 25rpx;
			background-color: #ffffff;
			box-shadow: inset 3rpx 4rpx 18rpx 0rpx rgba(0, 0, 0, 0.15);
			border-radius: 25rpx;
			border: solid 2rpx rgba(255, 255, 255, 0.9);
			position: relative;
			overflow: hidden;
			line-height: 25rpx;

			.jin_s {
				position: absolute;
				height: 100%;
				border-radius: 25rpx;
				z-index: 9;
				top: 0;
				left: 0;
				background-color: red;
			}
		}
	}

	.items_box:nth-child(2n) {
		margin-right: 0;
	}

	.hhfont {
		color: #E7D2C2;
		-webkit-text-stroke: 0.5rpx #795C46;
		text-stroke: 0.5rpx #795C46;
	}

	.left_scr {
		background-color: rgba(0, 0, 0, .3);
	}


	.tower-swiper .tower-item {
		transform: scale(calc(0.5 + var(--index) / 10));
		margin-left: calc(var(--left) * 100upx - 150upx);
		z-index: var(--index);
	}

	.refresh_icon {
		height: 80upx;
		width: 80upx;
	}

	.screen-swiper {
		min-height: 0rpx;
	}


	.sw_choose_default {
		display: inline-block;
		padding-right: 50rpx;
	}

	.sw_choose {
		color: #F9FADA;
		-webkit-text-stroke: 3rpx #8A5E51;
		font-size: 36rpx;
	}

	.sw_nochoose {
		color: #A6A2A2;
	}

	.con_left {
		margin-top: 15rpx;
		float: left;
		margin-left: 3%;
		border-radius: 12rpx;
	}

	.con_right {
		margin-top: 15rpx;
		float: right;
		margin-right: 3%;
		border-radius: 12rpx;
	}

	.robot_bottom {
		width: 91.9%;
		margin-left: 4.6%;
		border: 1px solid black;
		height: 60upx;
		border-radius: 10upx;
	}

	.robot_2_icon {
		height: 47upx;
		width: 55upx;
		margin-top: 4upx;
		margin-left: 13upx;
		float: left;
	}

	.robot_2_notice {
		margin-top: 10upx;
		margin-left: 15upx;
		font-size: 28upx;
		color: black;
		float: left;
		width: 85%;
		line-height: 18px;
	}

	.item_hot {
		position: absolute;
		z-index: 100;
		top: -30rpx;
		right: -28rpx;
	}

	.animation {

		animation-name: shake; // 动画名称
		animation-direction: 10; // 动画在奇数次（1、3、5...）正向播放，在偶数次（2、4、6...）反向播放。
		animation-timing-function: linear; // 动画执行方式，linear：匀速；ease：先慢再快后慢；ease-in：由慢速开始；ease-out：由慢速结束；ease-in-out：由慢速开始和结束；
		animation-delay: 0s; // 动画延迟时间
		animation-iteration-count: infinite; //  动画播放次数，infinite：一直播放
		animation-duration: 4s; // 动画完成时间
		animation-fill-mode: backwards;
	}

	@keyframes shake {
		0% {
			transform: rotate(0deg);
		}

		5% {
			transform: rotate(10deg);
		}

		10% {
			transform: rotate(-15deg);
		}

		15% {
			transform: rotate(15deg);
		}

		20% {
			transform: rotate(-15deg);
		}

		25% {
			transform: rotate(15deg);
		}

		30% {
			transform: rotate(-15deg);
		}

		35% {
			transform: rotate(15deg);
		}

		40% {
			transform: rotate(-15deg);
		}

		45% {
			transform: rotate(15deg);
		}

		50% {
			transform: rotate(-15deg);
		}

		55% {
			transform: rotate(15deg);
		}

		60% {
			transform: rotate(-15deg);
		}

		65% {
			transform: rotate(15deg);
		}

		70% {
			transform: rotate(-15deg);
		}

		75% {
			transform: rotate(15deg);
		}

		80% {
			transform: rotate(-15deg);
		}

		85% {
			transform: rotate(15deg);
		}

		90% {
			transform: rotate(-15deg);
		}

		95% {
			transform: rotate(10deg);
		}

		100% {
			transform: rotate(0deg);
		}
	}

	// 社区
	button:after {
		border: none;
	}

	.fl {
		float: left;
	}

	.fr {
		float: right;
	}

	/*组件背景颜色*/
	.zr {
		background: #AEE2DA;
		width: 100%;
		height: 400rpx;
		position: relative;
	}

	.water {
		position: absolute;
		left: 0;
		bottom: -10px;
		height: 30px;
		width: 100%;
		z-index: 1
	}

	.water-c {
		position: relative
	}

	.water-1 {
		background: url("") repeat-x;
		background-size: 600rpx;
		-webkit-animation: wave-animation-1 3.5s infinite linear;
		animation: wave-animation-1 3.5s infinite linear
	}

	.water-2 {
		top: 5px;
		background: url("") repeat-x;
		background-size: 600rpx;
		-webkit-animation: wave-animation-2 6s infinite linear;
		animation: wave-animation-2 6s infinite linear
	}

	.water-1,
	.water-2 {
		position: absolute;
		width: 100%;
		height: 60rpx;
	}

	.back-white {
		background: #fff
	}

	@keyframes wave-animation-1 {
		0% {
			background-position: 0 top
		}

		100% {
			background-position: 600rpx top
		}
	}

	@keyframes wave-animation-2 {
		0% {
			background-position: 0 top
		}

		100% {
			background-position: 600rpx top
		}
	}

	// 我的
	.btnitem {
		width: 48%;
		float: left;
		margin-right: 4%;
	}

	.btnitem:nth-child(2n) {
		margin-right: 0;
	}

	.schedule {
		border-radius: 15rpx;
		overflow: hidden;
	}

	.poke_item {
		position: relative;

		.item_img {
			position: absolute;
			z-index: 0;
		}

		.item_num {
			position: absolute;
			z-index: 9;
			top: 20rpx;
			left: 40rpx;
		}
	}

	.auto {
		margin: 0 auto;
	}

	button:after {
		border: none;
	}
</style>